package pers.ree.demo.designpattern.memento;

/**
 * 发起者：
 * 原始对象
 */
public class Originator {

    private int code;

    private String name;


    public Memento createMemeto() {
        return new Memento(this);
    }

    public void restoreFromMemeto(Memento memento) {
        this.code = memento.getCode();
        this.name = memento.getName();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "code:" + code + ", name:" + name;
    }
}
